<template>
  <div class="hot">
    <h3>{{ title }}</h3>
    <ul>
      <li v-for="item in hotList"  :key="item.id">
        <RouterLink  :to="`/detail/${item.id}`" >
          <img :src="item.picture" alt="">
          <p class="title">{{ item.title }}</p>
          <p class="desc">{{ item.desc }}</p>
          <p class="price">¥{{ item.price }}</p>
        </RouterLink>
      </li>
    </ul>
  </div>
</template>

<script setup name="ComponentName">
import { RouterLink } from 'vue-router';
import { getHotGoodsAPI } from '@/api/detail'
import { onMounted, reactive, ref } from 'vue'
import { useRoute } from 'vue-router';

const props = defineProps({
  title: {
    type: String,
    default: '24小时热榜',
  },
  type: {
    type: Number,
    default: 1,
  },
  limit: {
    type: Number,
    default: 10,
  }
})
const route = useRoute()

const queryParams = reactive({
  id: route.params.id,
  type: props.type,
  limit: props.limit,
})

const hotList = ref([])
const getHotList = async () => {
  const res = await getHotGoodsAPI(queryParams)
  hotList.value = res.result
}
onMounted(() => getHotList())



</script>

<style scoped lang="scss">
.hot {
  width: 100%;
  background: #fff;
  h3 {
    padding: 20px 10px;
    background: #f20909;
    color: #fff;
    margin-bottom: 10px;
  }
  ul {
    display: flex;
    width: 100%;
    flex-flow: column nowrap;
    justify-content: center;
    align-items: center;
    gap: 10px 0;
    li {
      width: 135px;
      border: 1px solid #ffffff00;
      a {
        width: 100%;
        height: 100%;
        img{
          width: 100%;
          height: 100%;
        }
        p {
          font-size: 14px;
          text-align: center;
          &.title {
            font-size: 16px;
          }
          &.desc {
            padding: 5px 0;
            overflow: hidden;
            text-overflow: ellipsis;
            white-space: nowrap;
          }
          &.price {
            font-size: 16px;
            color: #ff0000;
          }
        }
      }
      &:hover {
        border: 1px solid #cb7b7b;
        box-shadow: 0 0 10px #cb7b7b;
        transition: all 0.2s ease-in-out;
      }
    }
  }
}
</style>
